<%--
  Created by IntelliJ IDEA.
  User: teacher
  Date: 2023/7/18
  Time: 11:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户注册</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <script>
        $(function(){
           $("#username").blur(function(){
              $.ajax({
                  type:"post",
                  url:"${pageContext.request.contextPath}/checkUsername.user",
                  data:{"username":$(this).val()},
                  success:function(result){
                      console.log(result);
                      if(result == "success"){
                          $("#s1").html("<span style='color:green'>用户名校验成功</span>");
                          $("#register").attr("disabled",false);
                      } else{
                          $("#s1").html("<span style='color:red;'>该用户已经被注册</span>");
                          $("#register").attr("disabled",true);
                      }
                  }
              })
           });
        });
    </script>
</head>
<body>
<h1>用户注册</h1>
<a href="${pageContext.request.contextPath}/login.jsp">返回登录</a>
<hr>
<form action="${pageContext.request.contextPath}/register.user" method="post">
    用户名:<input type="text" name="username" id="username"><span id="s1"></span><br>
    密&nbsp;&nbsp;&nbsp;码:<input type="password" name="password"><br>
    电&nbsp;&nbsp;&nbsp;话:<input type="text" name="phone"><br>
    地&nbsp;&nbsp;&nbsp;址:<input type="text" name="address"><br>
    <input type="submit" id="register" value="注册">
</form>
</body>
</html>
